define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");

	var Model = function(){
		this.callParent();
		this.currentId = null;
		this.STORE_ID = "infoData";
	};

	Model.prototype.modelParamsReceive = function(event){
		this.currentId = this.getContext().getRequestParameter("currentId");
		this.comp("infoData").refreshData();
	};

	Model.prototype.infoDataCustomRefresh = function(event){
	    var me = this;
	    if(this.currentId){
	    	var url = "http://101.201.49.208:8080/ex_community/a/api/community/getClassInfosByCategoryId?callback=?&category.id="+this.currentId;			
			$.getJSON(
					url,
					function(data){
					   // console.log('test',data);
					   
						me.comp("infoData").loadData(data);
					    localStorage.setItem(me.STORE_ID, JSON.stringify(data));	//保存本地			
					}
			);
	    }else{
	       // console.log('local',JSON.parse(localStorage.getItem(me.STORE_ID)));
	    	me.comp("infoData").loadData(JSON.parse(localStorage.getItem(me.STORE_ID)));	    	
	    }
		
		
	};
	
	Model.prototype.createImageUrl = function(path){
	  
		var url = "http://101.201.49.208:8080"+path;
		return url;
	};

	Model.prototype.infoListClick = function(event){
	    var catInfoId = this.comp("infoData").getCurrentRow().val('id');
		justep.Shell.showPage("$UI/communityOto/category/categoryInfo.w?catInfoId=" + catInfoId);
	};

	Model.prototype.backBtnClick = function(event){
		justep.Shell.showPage("$UI/communityOto/category/categoryFragment.w");
	};

	return Model;
});